<template>
  <a-card style="width: 100%" title="操作记录">
    <template #extra>
      <a-tooltip placement="top">
        <template #title>
          <span>返回上级</span>
        </template>
        <a-button size="small" @click="getOut"> <RollbackOutlined /></a-button>
      </a-tooltip>
    </template>
    <a-row class="smart-table-btn-block">
      <div class="smart-table-operate-block"></div>
      <div class="smart-table-setting-block">
        <TableOperator v-model="columns" :tableId="TABLE_ID_CONST.BUSINESS.OA.ENTERPRISE" :refresh="getInitDate" />
      </div>
    </a-row>
    <a-table size="small" :dataSource="tableData" :columns="columns" rowKey="enterpriseId" :pagination="false" :loading="tableLoading" bordered>
    </a-table>
    <!-- 分页-->
    <div class="smart-query-table-page">
      <a-pagination
        showSizeChanger
        showQuickJumper
        show-less-items
        :pageSizeOptions="PAGE_SIZE_OPTIONS"
        :defaultPageSize="queryForm.limit"
        v-model:current="queryForm.page"
        v-model:pageSize="queryForm.limit"
        :total="total"
        @change="getInitDate"
        @showSizeChange="getInitDate"
        :show-total="(total) => `共${total}条`"
      />
    </div>
  </a-card>
  <br />
</template>

<script setup>
  import { reactive, ref, onMounted, defineEmits, defineProps } from 'vue';
  import { message, Modal } from 'ant-design-vue';
  import { SmartLoading } from '/@/components/framework/smart-loading';
  import { Instantly } from '/@/api/instantly/instantly-api';
  import { PAGE_SIZE, PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
  import TableOperator from '/@/components/support/table-operator/index.vue';
  import { TABLE_ID_CONST } from '/@/constants/support/table-id-const';
  import { ProManageApi } from '../../../../api/ProManage/ProManage-api';
  import { smartSentry } from '/@/lib/smart-sentry';
  //--------------------------- 表格 列 ---------------------------
  const columns = ref([
    {
      title: '项目名称',
      dataIndex: 'blprojectname',
      align: 'center',
    },
    {
      title: '操作人',
      dataIndex: 'blname',
      align: 'center',
    },

    {
      title: '操作时间',
      dataIndex: 'blactiondate',
      align: 'center',
    },
    {
      title: '操作类型',
      dataIndex: 'blaction',
      align: 'center',
    },
  ]);
  const queryFormState = {
    page: 1,
    limit: PAGE_SIZE,
  };
  const queryForm = reactive({ ...queryFormState });
  const tableLoading = ref(false);
  const tableData = ref([]);
  const total = ref(0);
  //拿到数据id查看该数据的操作记录
  const props = defineProps({
    DateId: String,
  });
  async function getInitDate() {
    try {
      queryForm.key = props.DateId;
      let res = await ProManageApi.ConLogProManage(queryForm);
      console.log(res, '操作记录');
      tableData.value = res.page.list;
      total.value = res.page.totalCount;
    } catch (error) {
      smartSentry.captureError(error);
    }
  }
  const emit = defineEmits();
  //返回表格
  const getOut = () => {
    let obj = {
      type: 0,
    };
    emit('getBlack', obj);
  };
  onMounted(() => {
    getInitDate();
  });
</script>

<style lang="scss" scoped></style>
